package site.zhouinfo.zhihuproblem;

import java.util.concurrent.CountDownLatch;

import static site.zhouinfo.zhihuproblem.KillNumber.CPU_CORE;
import static site.zhouinfo.zhihuproblem.KillNumber.CYCLE_INDEX;
import static site.zhouinfo.zhihuproblem.KillNumber.cycleProcess;
import static site.zhouinfo.zhihuproblem.KillNumber.list;
import static site.zhouinfo.zhihuproblem.KillNumber.surviveNumber;

/**
 * 多线程处理
 *
 * @author zhou
 * @create 2017-02-17 17:37
 * @email zhouinfo@qq.com
 */
public class KillNumberThread implements Runnable {

    private CountDownLatch latch;

    public KillNumberThread(CountDownLatch latch) {
        this.latch = latch;
    }

    @Override
    public void run() {
        for (int j = 0; j < CYCLE_INDEX / CPU_CORE; j++) {
            surviveNumber[cycleProcess(list) - 1]++;
        }
        System.out.println(Thread.currentThread().getName());
        latch.countDown();
    }


}
